package com.itheima.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

//    @Bean
//    public MapperScannerConfigurer getMapperScannerConfigurer() {
//        MapperScannerConfigurer configurer = new MapperScannerConfigurer();
//        configurer.setBasePackage("com.itheima.dao");
//        return configurer;
//    }
//
//    @Bean
//    public MybatisSqlSessionFactoryBean getSqlSessionFactoryBean(
//            DataSource dataSource,
//            @Value("classpath:myBatisConfig.xml")
//                    Resource myBatisConfigResource,
//            @Value("classpath:mapper/*.xml") Resource[] mapperResource) {
//        MybatisSqlSessionFactoryBean sqlSessionFactoryBean =
//                new MybatisSqlSessionFactoryBean();
//        sqlSessionFactoryBean.setDataSource(dataSource);
//        sqlSessionFactoryBean.setTypeAliasesPackage("com.itheima.entity");
//        sqlSessionFactoryBean.setConfigLocation(myBatisConfigResource);
//        sqlSessionFactoryBean.setMapperLocations(mapperResource);
//        return sqlSessionFactoryBean;
//    }

}
